import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router);
const originalPush = Router.prototype.push;

Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
};
export default new Router({
  routes: [
    {
      path: '/',
      redirect:'/home'
    },
    {
      path: '/home',
      name:'home',
      component:()=>import("@/views/home.vue")
    },
    {
      path: '/login',
      name: 'login',
      component:()=>import("@/views/login.vue")
    },
    {
      path:'/register',
      name:'register',
      component:()=>import("@/views/register.vue")
    },
    //管理员入口
    {
      path:'/admin/userAdmin',
      name:'userAdmin',
      component:()=>import("@/views/admin/userAdmin.vue")
    },
    {
      path:'/recycling',
      name:'recycling',
      component:()=>import("@/views/recycling.vue")
    },
    {
      path:'/lowPrice',
      name:'lowPrice',
      component:()=>import("@/views/lowPrice.vue")
    },
    {
      path:'/offline',
      name:'offline',
      component:()=>import("@/views/offline.vue")
    },
    {
      path:'/admin/orderAdmin',
      name:'orderAdmin',
      component:()=>import("@/views/admin/orderAdmin.vue")
    },
    {
      path:'/admin/cardAdmin',
      name:'cardAdmin',
      component:()=>import("@/views/admin/cardAdmin.vue")
    },
    {
      path:'/admin/recardAdmin',
      name:'recardAdmin',
      component:()=>import("@/views/admin/recardAdmin.vue")
    },
    {
      name:'selfCenter',
      path:'/self-center',
      component:()=>import('@/views/self/selfCenter.vue')
    },
    {
      name:'orderInfo',
      path:'/lowPrice-order',
      component:()=>import("@/views/self/orderInfo.vue")
    },
    {
      name:'success',
      path:'/success',
      component:()=>import('@/views/success.vue')
    },
    {
      name:'offlineOrder',
      path:'/offline-order',
      component:()=>import('@/views/self/offlineOrder.vue')
    },
    {
      name: 'recard-order',
      path: '/recard-order',
      component: () => import('@/views/self/recard-order.vue')
    },
    {
      name:'offlineAdmin',
      path:'/admin/offlineAdmin',
      component:()=>import('@/views/admin/offlineAdmin.vue')
    },
    {
      name:'newsAdmin',
      path:'/admin/newsAdmin',
      component:()=>import('@/views/admin/newsAdmin.vue')
    }
  ]
})
